module.exports = Behavior({
  data: {
    pageNum: 0,
    pageSize: 30,
    nomore: false,
    list: [],
  },
  created(){

  },
  methods: {
      /**
    * 获取工作室全部商品列表
    */
    async getList(){
      const token = wx.getStorageSync('token')
      const pageNum = this.data.pageNum + 1
      const data = {
        studioId: this.data.studioId, 
        pageNum,
        pageSize: this.data.pageSize
      }
      const res = await getListApi(token, data)
      if (res.data.code === 200) {
        const total = res.data.total
        const pages = Math.ceil(total / this.data.pageSize)
        const oldList = this.data.aiRecommendList
        if (pageNum >= pages) {
          this.setData({
            nomore: true,
          })
        }

        res.data.total !== 0 && this.setData({
          list: [...oldList, ...res.data.rows],
          pageNum
        })
      }else if (res.data.code === 401) {
        app.login(wx.getStorageSync('phone'))
      }else if (res.data.code === 500) {
        wx.showToast({
          title: res.data.msg,
          mask: true,
          icon: 'none'
        })
      }
    },
  }
})